/**
 * Created by zengy on 2017/6/15.
 */
//商品设置
var http = HttpRequest.prototype;
//1.查询商品列表
http.getGoodsList=function (params,cb) {
    var opts = {
        url : baseUrl + '/manager/wxGoods/queryWxGoodsList',
        type : 'POST',
        data:params
    };
    this.baseRequest(cb,opts)
}
//查看商品
http.getGoodDetail=function (params,cb) {
    var opts = {
        url : baseUrl + '/manager/wxGoods/getWxGoodsDetail',
        type : 'POST',
        data:params
    };
    this.baseRequest(cb,opts)
}
//上传文件

http.uploadFile = function (current,fileType,callback) {
    var url = '';
    if(fileType == 'img'){
        url = uploadApiUrl + 'live/uploadImg';
    }else if(fileType == 'video'){
        url = uploadApiUrl + 'live/uploadVideoPublic';
    }else if(fileType == 'zip'){
        url = uploadApiUrl + 'live/zipv2';
    }else if(fileType == 'file'){
        url = uploadApiUrl + 'live/uploadFile';
    }
    else if(fileType == 'newimg'){
        url = uploadApiUrl +'app/v2/image?METHOD=uploadimageforop&code=guidance'
    }
    else if(fileType == 'xlsx' || fileType == 'xls'){
        url = uploadApiUrl + 'common/preVip/uploadExcel?suffix='+fileType;
    }
    var formData = new FormData();
    var fileObj = current.files;
    for (var i = 0; i < fileObj.length; i++){
        formData.append("web", fileObj[i]);
    }
    $.ajax({
        type: 'POST',
        url: url,
        data: formData,
        contentType: false,
        processData: false,
        complete: function (XMLHttpRequest, textStatus) {
            var json = '';
            try{
                json = JSON.parse(XMLHttpRequest.responseText);
            }catch(e){
                json = {
                    code : '99999',
                    msg : '服务器错误'
                }
            }
            callback(json,textStatus);
        }
    });
};
//编辑保存
http.modGoodsDetail=function (params,cb) {
    var opts = {
        url : baseUrl + '/manager/wxGoods/modifyWxGoods',
        type : 'POST',
        data:params
    };
    this.baseRequest(cb,opts)
}
///manager/wxGoods/getDeptsAndPackages
http.getDeptsAndPackages=function (cb) {
    var opts = {
        url : baseUrl + '/manager/wxGoods/getDeptsAndPackages',
        type : 'POST',
        data:params
    };
    this.baseRequest(cb,opts)
}
//上架
http.updateWxGoodsStatus=function (params,cb) {
    var opts = {
        url : baseUrl + '/manager/wxGoods/updateWxGoodsStatus',
        type : 'POST',
        data:params
    };
    this.baseRequest(cb,opts)
}
//下载二维码
http.downloadRcode=function (params,cb) {
    var opts={
        url:baseUrl+'/manager/wxGoods/getQRcode',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}
//删除
http.deleteWxGoods=function (params,cb) {
    var opts={
        url:baseUrl+'/manager/wxGoods/deleteWxGoods',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}
//查看编辑详情
http.getWxGoodsDetail=function (params,cb) {
    var opts={
        url:baseUrl+'/manager/wxGoods/getWxGoodsDetail',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}
//查询服务医生
http.searchDoctorList=function (params,cb) {

    var opts={
        url:baseUrl+'/doctorManager/getOneByNamePhone',
        type:'POST',
        data:{nameOrPhone:params}
    }
    this.baseRequest(cb,opts)
}
//查询商品关联服务项
http.queryWxGoodsDetailForPackages=function (params,cb) {

    var opts={
        url:baseUrl+'/manager/ wxGoods/queryWxGoodsDetailForPackages',
        type:'POST',
        data:{wxGoodsId:params}
    }
    this.baseRequest(cb,opts)
}
//查询商品不包含的服务项

http.otherServicesListByGoods=function (params,cb) {

    var opts={
        url:baseUrl+'/manager/ wxGoods/otherServicesListByGoods',
        type:'POST',
        data:{wxGoodsId:params}
    }
    this.baseRequest(cb,opts)
}
//添加套餐服务
http.insertWxGoodsDetail=function (params,cb) {

    var opts={
        url:baseUrl+'/manager/wxGoodsDetail/insertWxGoodsDetail',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}
//服务上移下移
http.upDownChange=function (params,cb) {

    var opts={
        url:baseUrl+'/manager/ wxGoodsDetail/upDownChange',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}

//删除套餐服务
http.deleteServicesByGoods=function (params,cb) {

    var opts={
        url:baseUrl+'/manager/wxGoodsDetail/deleteServicesByGoods',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}
//获取服务协议

http.getServiceAgreement=function (params,cb) {

    var opts={
        url:baseUrl+'/wxjs/getServiceAgreement',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}
//编辑套餐协议
http.modifyWxGoodsServiceAgreement=function (params,cb) {

    var opts={
        url:baseUrl+'/manager/wxGoods/modifyWxGoodsServiceAgreement',
        type:'POST',
        data:params
    }
    this.baseRequest(cb,opts)
}